// 云函数入口文件
const cloud = require('wx-server-sdk')
const cheerio = require('cheerio');
const axios = require('axios');


cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  axios.get('https://www.cnblogs.com/masterchd/')
    .then(function (response) {
      // console.log(response);
      console.log(response)
      let htmldata = response.data;
      $ = cheerio.load(htmldata)
      let postlist = [];
      $('a.vertical-middle').each(function(i,ele){
        postlist.push($(this).attr('href'))
      })
      let titlelist = []
      $('a.vertical-middle span').each(function(i,ele){
        titlelist.push($(this).text().trim())
      })
      console.log(postlist)
      console.log(titlelist)
    })
}